# main.py
from PyQt6 import QtWidgets
from PyQt6.QtCore import pyqtSlot,Qt
from PyQt6.QtGui import QFont
import sys
import os

from .Ui_arm_set import Ui_Dialog  # 这是 pyuic6 自动生成的类

class ArmSetDialog(QtWidgets.QDialog, Ui_Dialog):
    def __init__(self):
        super().__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        # UI 初始化后，设置逻辑
        self.init_ui_logic()

    def init_ui_logic(self):
        a=1



# 启动程序
def main():
    os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"

    app_arm_set = QtWidgets.QApplication(sys.argv)

    # 可选：根据 DPI 缩放字体
    screen_arm_set = app_arm_set.primaryScreen()
    dpi_arm_set = screen_arm_set.logicalDotsPerInch()
    scale_arm_set = dpi_arm_set / 96.0
    font_arm_set = QFont("Microsoft YaHei", int(10 * scale_arm_set))
    app_arm_set.setFont(font_arm_set)

    dlg_arm_set = ArmSetDialog()
    dlg_arm_set.show()
    sys.exit(app_arm_set.exec())

def run():
    app = QtWidgets.QApplication.instance()
    if app is not None:
        screen = app.primaryScreen()
        dpi = screen.logicalDotsPerInch()
        scale = dpi / 96.0
        font = QFont("Microsoft YaHei", int(10 * scale))
        app.setFont(font)

    dlg = ArmSetDialog()
    dlg.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
    dlg.show()
    return dlg

if __name__ == '__main__':
    main()